package com.springboot.mybatis.service.rabbitmq;

import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author sunyt31481
 * @date 2020/8/12 14:41
 * @description
 */
public class Customer2WorkDemo {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connect = RabbitMqUtil.getConnect();
        Channel channel = connect.createChannel();
        channel.queueDeclare("helloWork", true, false, false,null);
        channel.basicConsume("helloWork", true, new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                System.out.println(new String(body));
                channel.basicAck(envelope.getDeliveryTag(), false);
            }
        });
    }
}
